require 'active_record/fixtures'

class CreateDb < ActiveRecord::Migration
	def self.up
		opts = {:force => true, :options => 'ENGINE = InnoDB'}

		create_table(:confs, opts) { |t|
			t.column :name,	:string,	:limit => 20,		:null => false
			t.column :value, :string, :limit => 1024,	:null => false
		}

		create_table(:events, opts) { |t|
			t.column :video_id,	:integer,	:null => false
			t.column :status_id, :integer,	:null => false
			t.column :created_on, :datetime
		}

		create_table(:video_status, opts) { |t|
			t.column :name, :string, :limit => 20, :null => false
		}

		create_table(:videos, opts) { |t|
			t.column :nf_id,					:integer,									:null => false
			t.column :status_id,			:integer,									:null => false, :default => VideoStatus::DOWNLOADING
			t.column :title,					:string,	:limit => 255,	:null => false, :default => ''
			t.column :remote_url,			:string,	:limit => 255,	:null => false, :default => ''
			t.column :download_url,		:string,	:limit => 255,	:null => false, :default => ''
			t.column :file_name,			:string,	:limit => 1024,	:null => false, :default => ''
			t.column :bitrate,				:integer,									:null => false
		}
	end

	def self.down
		drop_table :confs
		drop_table :events
		drop_table :video_status
		drop_table :videos
	end
end
